import { computed } from "vue";
import { PC_DEVICE_WIDTH } from "@/constants";
import { useWindowSize } from "@vueuse/core";
const {width} = useWindowSize();

// 判断当前是否为移动设备，判断依据为屏幕的宽度是否大于指定值(1280)

export const isMobileTerminal = computed(() => {
    // const {clientWidth} = document.clientWidth;
    // return clientWidth < PC_DEVICE_WIDTH;

    // return /Android | webOS | iPhone | iPad | iPod | BlackBerry | IEMobile | Opera Mini/i.test(navigator.userAgent)
   
   
    return width.value < PC_DEVICE_WIDTH;
}) 


export const useREM = () => {
    const MAX_FONT_SIZE = 40;
    document.addEventListener('DOMContentLoaded', () => {
        const html = document.querySelector('html');
        let fontSize = window.innerWidth / 10;
        fontSize = fontSize > MAX_FONT_SIZE ? MAX_FONT_SIZE : fontSize;
        html.style.fontSize = fontSize + 'px';
    })
}